<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script>
        $(function () {
            $("#telephone").blur(function () { 
                if(this.value==""){
                    return false;
                }
                $.get("checkPhoneServlet",{phone:this.value},function (result) {//result就是服务端返回的值
                    if(result=="true"){
                        alert("此手机已经被注册");
                        $(":submit").attr("disabled",true);
                    }else{
                        alert("此手机可以使用");
                        $(":submit").attr("disabled",false);
                    }
                });
            });
        });
    </script>
   <%-- <script>
        function checkPh(t) {
            if(t.value=="")
                return false;

            var xhr=new XMLHttpRequest();
            xhr.onreadystatechange=function (ev) {
                if(xhr.readyState==4&&xhr.status==200){
                    var result=xhr.responseText;//
                    if(result=="true"){
                        alert("手机号已经注册了");
                    }else{
                        alert("手机号可以用");
                    }
                }
            }
            xhr.open("get","checkPhoneServlet?phone="+t.value,true);
            xhr.send(null);
        }
    </script>--%>
</head>
<body>

<form action="DoAddStudentServlet" method="post" enctype="multipart/form-data">

    <fieldset>
        <legend>学生信息</legend>
        <label for="">
            姓名: <input type="text" pattern="[\u4E00-\u9FA5]{2,10}" required autofocus placeholder="请输入姓名"  name="sname">
        </label>
        <label for="">
            性别:
            <div id="gender">
                <input type="radio" name="sex" value="男" checked="checked" class="gender"  /> <img
                    src="images/man.jpg"/>&nbsp;男&nbsp;&nbsp;&nbsp;
                <input type="radio" name="sex" value="女" class="gender"/> <img src="images/women.jpg"/>&nbsp;女&nbsp;
                <input type="radio" name="sex" value="妖" class="gender"/> <img src="images/women.jpg"/>&nbsp;妖&nbsp;
            </div>
        </label>
        <label for="">手机号码: <input type="tel" pattern="1[3578]\d{9}" placeholder="请输入手机号码" name="telephone" id="telephone">
        </label>
        <label for="">QQ: <input type="text" placeholder="请输入QQ" name="qq">
        </label>
        <label for="">微信: <input type="text" placeholder="请输入微信" name="wechat" >
        </label>
        <%--<label for="">--%>
        <%--邮箱地址: <input type="email" placeholder="请输入邮箱地址">--%>
        <%--</label>--%>
        <label for="">
            年级:
            <select name="gradeid" id="gradeid">
                <c:forEach items="${grades}" var="g">
                    <option value="${g.id}">${g.gname}</option>
                </c:forEach>
            </select>
        </label>
        <label for="">
            入学日期: <input name="enterdate" type="date" >
        </label>
        <label for="">起运地: <input type="text" placeholder="请输入起运地" name="fromcity" >
        </label>
        <label for="">
            生日: <input name="birthday" type="date" >
        </label>
        <label for="">住址: <input type="text" placeholder="请输入住址" name="address" >
        </label>
        <%-- <label for="">密码: <input type="password" placeholder="请输入密码" name="pass">
         </label>--%>
        <label for="">居民身份证图片: <input type="file" placeholder="请输入居民身份证图片" name="idcardpic">
        </label>
        <label for="" class="btn">
            <input type="submit" value="保存" style="font-size: 22px">
        </label>
    </fieldset>
</form>
<script>

</script>
</body>
</html>
